package com.robot.orders.client;

import com.robot.orders.client.impl.CouponClientImpl;
import com.robot.orders.pojo.client.Coupon;
import entity.PageResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @author lin
 */
@Component
@FeignClient(value = "robot-coupon", fallback = CouponClientImpl.class)
public interface CouponClient {
    /**
     * 根据会员ID查找该会员名下特定状态的所有优惠券并分页
     *
     * @param memberId
     * @param status
     * @param page
     * @param size
     * @return
     */
    @GetMapping(value = "coupon/third/findCouponsByMemberIdAndStatus/{memberId}/{status}/{page}/{size}", produces = "application/json; charset=utf-8")
    public String thirdFindCouponsByMemberIdAndStatus(@PathVariable String memberId, @PathVariable String status, @PathVariable int page, @PathVariable int size) ;

    /**
     * 根据会员ID查找该会员名下的某张优惠券
     *
     * @param id
     * @param memberId
     * @return
     */
    @GetMapping(value = "coupon/third/findCouponByIdAndMemberId/{id}/{memberId}", produces = "application/json; charset=utf-8")
    public String thirdFindCouponByIdAndMemberId(@PathVariable String id, @PathVariable String memberId);

    /**
     * 传入对象来修改coupon
     *
     * @param coupon
     */
    @PutMapping(value = "coupon/third/updateCouponByCoupon", produces = "application/json; charset=utf-8")
    @Transactional(rollbackFor = Exception.class)
    public void thirdUpdateCouponByCoupon(@RequestBody String coupon);
}
